﻿using Edge.Repository.Model.CameraSys;
using Edge.Repository.Model.CameraSys.CDal;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CameraClient.CForm.CameraF
{
    public partial class FormWenDu : Form
    {
        public FormWenDu()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            // 取消
            this.DialogResult = DialogResult.Cancel;
        }

        private void button2_Click(object sender, EventArgs e)
        {

            int MaxWenDu = (int)numericUpDown1.Value;
            int MinWenDu = (int)numericUpDown2.Value;

            if (MaxWenDu <= MinWenDu)
            {
                MessageBox.Show("最大温度要大于最小温度！");
                return;
            }

            CameraService dal = new CameraService();
            List<CameraConfigModel> cameras = dal.Query();
            foreach (CameraConfigModel cam in cameras)
            {

                cam.MaxWenDu = MaxWenDu;
                cam.MinWenDu = MinWenDu;

                dal.Update(cam);
            }

            MessageBox.Show("保存成功！");
            this.DialogResult = DialogResult.OK;
        }
    }
}
